<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/include.inc.jsp" %>

<%@include file="/WEB-INF/views/layout/base.ref.jsp" %>
<style type="text/css">
    .form-horizontal .form-group {
        margin-left: 0px;
        margin-right: 0px;
    }
</style>
<form id="inputinfoform" class="form-horizontal">
    <input type="hidden" name="id" value="${inputInfo.id}">
    <input type="hidden" name="useId" value="${inputInfo.useId}">
    <input type="hidden" name="organizeId" value="${inputInfo.organizeId}">
    <div class="form-group form-group-xs">
        <label class="col-xs-2 control-label">标题</label>
        <div class="col-xs-10">
            <input class="form-control" type="text" name="caption" value="${inputInfo.caption}" placeholder="标题">
        </div>
    </div>
    <div class="form-group form-group-xs" style="display: none;">
        <label class="col-xs-2 control-label">标识</label>
        <div class="col-xs-10">
            <input class="form-control" type="text" name="mark" value="${inputInfo.mark}" placeholder="标题">
        </div>
    </div>
    <div class="form-group form-group-xs">
        <label class="col-xs-2 control-label">类型</label>
        <div class="col-xs-10">
            <select class="form-control" id="typeName" name="typeName">
                <option value="text">
                    文本
                </option>
                <option value="number">
                    数字
                </option>
                <option value="select">
                    选择
                </option>
                <option value="date">
                    日期
                </option>
                <option value="batch">
                    批号
                </option>
            </select>
        </div>
    </div>
    <div class="form-group form-group-xs number ">
        <label class="col-xs-2 control-label">最小值</label>
        <div class="col-xs-10">
            <input class="form-control" type="text" name="minVal" value="${inputInfo.minVal eq null?0:inputInfo.minVal}"
                   placeholder="最小值">
        </div>
    </div>
    <div class="form-group form-group-xs number">
        <label class="col-xs-2 control-label">最大值</label>
        <div class="col-xs-10">
            <input class="form-control" type="text" name="maxVal" value="${inputInfo.maxVal eq null?0:inputInfo.maxVal}"
                   placeholder="最大值">
        </div>
    </div>
    <div class="form-group form-group-xs selectControl">
        <label class="col-xs-2 control-label batch">批号(双击选择)</label>
        <label class="col-xs-2 control-label select">选项<br/>(每项","分割)</label>
        <div class="col-xs-10">
            <input class="form-control" type="text" name="selectItem" sysSelectResultName="result2_99999"
                   onclick="selectControlFun()" value="${inputInfo.selectItem}" placeholder="批号">
        </div>
    </div>
    <div class="form-group form-group-xs defaultval">
        <label class="col-xs-2 control-label">默认值</label>
        <div class="col-xs-10">
            <input class="form-control" type="text" name="defaultVal" value="${inputInfo.defaultVal}" placeholder="默认值">
        </div>
    </div>
    <div class="form-group form-group-xs">
        <label class="col-xs-2 control-label">是否必填</label>
        <div class="col-xs-10">
            <div class="checkbox">
                <label>
                    <input type="hidden" name="isRequire" value="${inputInfo.isRequire}">
                    <input type="checkbox" id="isRequireCheck" ${inputInfo.isRequire == 1 ?"checked='checked'":""}>是否必填
                </label>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
    $(function () {

        //绑定下拉控件事件
        $("#typeName").on("change", function () {
            var type = $("#typeName").val();
            displayinfo(type);
        });

        //绑定复选框事件
        $("#isRequireCheck").on("change", function () {
            $("input[name='isRequire']").val($("#isRequireCheck").is(":checked") ? 1 : 0);
        });

        //绑定名称文本框事件，保存标识和名称一致
        $("input[name='caption']").on("blur", function () {
            $("input[name='mark']").val($("input[name='caption']").val());
        });

        if ('${inputInfo.typeName}') {
            $("#typeName").val("${inputInfo.typeName}");
        }

        $("#typeName").change();
    })

    //控制不同类型输入项显示内容
    function displayinfo(type) {
        $("#inputinfoform").find(".number,.selectControl,.select,.batch").hide();
        switch (type) {
            case "text":
                $(".defaultval").show();
                break;
            case "number":
                $("#inputinfoform .number").show();
                $(".defaultval").show();
                break;
            case "select":
                $("#inputinfoform .select,#inputinfoform .selectControl").show();
                $(".defaultval").show();
                selectControlFun = empty;
                break;
            case "batch":
                $("#inputinfoform .batch,#inputinfoform .selectControl").show();
                $(".defaultval").hide();
                selectControlFun = getPh;
                break;
        }
    }

    //选择批号
    function getPh() {
        meeting.customsearch("selectCustomCode", {index: 99999, multiple: true});
    }

    function empty() {

    }
</script>
